import request from '/@/utils/request.ts'
import { IGroupRuleData, IGroupListData } from '/@/entity/good'

export const defaultGroupRuleData: GroupRuleData = {
	name: '', //规则名称
	minimumNum: null, //最低成团人数
	winningProportion: null, //拼中人员比例
	subsidiesProportion: null, //补贴比例
	isUnified: 1, //是否在统一概率池，1：是，2：不是
	givingProportion: null //赠送比例
}

export const defaultGroupListData: IGroupListData = {
	goodsId: null, //商品id
	rulesId: null, //规则id
	startTime: '', //开团时间
	endTime: '' //结束时间
}

//--------------------------------------拼团规则---------------------------------------
//获取拼团规则分页集合
export const getGoodsSellingRulesList = (data: any): any =>
	request({
		url: '/goods/getGoodsSellingRulesList',
		method: 'get',
		params: data
	})

//添加拼团规则
export const addGoodsSellingRules = (data: any): any =>
	request({
		url: '/goods/addGoodsSellingRules',
		method: 'post',
		params: data
	})

//更新拼团规则
export const updateGoodsSellingRules = (data: any): any =>
	request({
		url: '/goods/updateGoodsSellingRules',
		method: 'post',
		params: data
	})

//---------------------------------------拼团列表---------------------------------------
//获取拼团商品
export const getGoodsSellingList = (data: any): any =>
	request({
		url: '/goods/getGoodsSellingList',
		method: 'get',
		params: data
	})

//添加拼团商品	POST /goods/addGoodsSelling
export const addGoodsSelling = (data: any): any =>
	request({
		url: '/goods/addGoodsSelling',
		method: 'post',
		params: data
	})

//更新拼团商品 POST /goods/updateGoodsSelling
export const updateGoodsSelling = (data: any): any =>
	request({
		url: '/goods/updateGoodsSelling',
		method: 'post',
		params: data
	})